<template>
  <a-card>
    <div class="ant-card-head-wrapper">
      <div class="ant-card-head-title">
        <span class="title">保健-身高体重</span>
        <span class="subtitle">最近{{pageSize}}条记录</span>
      </div>
      <div class="ant-card-extra">
        <a-button type="primary" @click="handleType('bmi')">查看详情<a-icon type="caret-right" /></a-button>
      </div>
    </div>
    <div class="card-content">
      <!-- table区域-begin -->
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true, y: 180}"
        bordered
        rowKey="id"
        :columns="bmi.columns"
        :dataSource="bmi.dataSource"
        :pagination="false"
        :loading="bmi.loading"
        class="j-table-force-nowrap">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-space>
            <!-- <a @click="handleDetail(record)">查看</a> -->
            <a @click="handleEdit(record)">编辑</a>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
          </a-space>
        </span>
      </a-table>
    </div>
    <sk-bmi-record-modal ref="modalForm" @ok="modalFormOk"></sk-bmi-record-modal>
  </a-card>
</template>
<script>
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import SkBmiRecordModal from '../../health/modules/SkBmiRecordModal'
import { getAction } from '@/api/manage';

export default {
  name: 'bmi',
  mixins:[JeecgListMixin, mixinDevice],
  data() {
    return {
      url: {
        bmilist: "health/skBmiRecord/list",
        delete: "/health/skBmiRecord/delete",
      },
      studentId: '',
      dataDate: '',
      nextDate: '',
      pageSize: 5,
      bmi: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:50,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'测量时间',
            align:"center",
            width:200,
            dataIndex: 'measurementTime'
          },
          {
            title:'身高(cm)',
            align:"center",
            width:100,
            dataIndex: 'height'
          },
          {
            title:'体重(kg)',
            align:"center",
            width:100,
            dataIndex: 'weight'
          },
          {
            title:'BMI',
            align:"center",
            // width:100,
            dataIndex: 'bmi'
          },
          {
            title:'体型',
            align:"center",
            width:80,
            dataIndex: 'status_dictText'
          },
          {
            title:'身高',
            align:"center",
            width:80,
            dataIndex: 'heightStatus_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            width:200,
            scopedSlots: { customRender: 'action' }
          }
        ],
      },
    }
  },
  props:[],
  components: {
    SkBmiRecordModal
  },
  filters: {},
  
  computed: {},
  
  created() {
    this.dataDate = this.$skCommon.getDate(0)
    this.nextDate = this.$skCommon.getDate(0)
  },
  
  activated() {
  },

  mounted() {
    // this.load();
  },

  methods: {
    load(dataForm) {
      this.dataDate =  dataForm.dataDate
      this.nextDate =  dataForm.dataDate
      this.studentId = dataForm.studentId
      this.loadData();
    },
    loadData() {
      let params = {
        studentId: this.studentId,
        // startDate: this.dataDate,
        // endDate: this.nextDate
      }
      this.bmi.loading = true
      getAction(this.url.bmilist, params).then(res => {
        this.bmi.loading = false
        if(res.success) {
          console.log(res.result)
          this.bmi.dataSource = res.result.records.slice(0,this.pageSize)
        }else {
          this.$message.warning(res.message);
        }
      }).catch(()=>{
        this.bmi.loading = false
      })
    },
    handleType(type){
      this.$emit('detail', type)
    },
  }
}
</script>
<style scoped lang="less">

</style>